declare i32 @printf(i8* , ...)
declare i8* @strcat(i8* , i8* )
declare i32 @strlen(i8*)
declare double @llvm.pow.f64(double, double)
declare double @atof(i8*)
declare i32 @sprintf(i8*, i8*, ...)
declare i8* @malloc(i32)
declare void @llvm.memset.i32(i8* , i8, i32, i32)
declare i8* @strcpy(i8* , i8*)
declare i32 @strcmp(i8*, i8*)
@ftoa.str = internal constant [3 x i8] c"%f\00"
@false.str = internal constant [6 x i8] c"false\00"
@true.str = internal constant [5 x i8] c"true\00"
@global.page = common global i8* null
@string0 = constant [44 x i8] c"one line\0Anext line\0A\22in quotes\22, 'in quotes'\00"
@print0 = constant [5 x i8] c"%s\09\0A\00"
@string1 = constant [31 x i8] c"a backslash inside quotes: '\5C'\00"
@print1 = constant [5 x i8] c"%s\09\0A\00"
@string2 = constant [19 x i8] c"a simpler way: '\5C'\00"
@print2 = constant [5 x i8] c"%s\09\0A\00"
@string3 = constant [113 x i8] c"<HTML>\0A<HEAD>\0A<TITLE>An HTML Page</TITLE>\0A</HEAD>\0A<BODY>\0ALua\0A[[a text between double brackets]]\0A</BODY>\0A</HTML>\0A\00"
@print3 = constant [5 x i8] c"%s\09\0A\00"
@string4 = constant [3 x i8] c"10\00"
@print4 = constant [5 x i8] c"%f\09\0A\00"
@string5 = constant [7 x i8] c"10 + 1\00"
@print5 = constant [5 x i8] c"%s\09\0A\00"
@string6 = constant [8 x i8] c"-5.3e-2\00"
@string7 = constant [2 x i8] c"2\00"
@print6 = constant [5 x i8] c"%f\09\0A\00"
@string8 = constant [6 x i8] c"hello\00"
@string9 = constant [6 x i8] c"world\00"
@print7 = constant [5 x i8] c"%s\09\0A\00"
@print8 = constant [5 x i8] c"%f\09\0A\00"
@print9 = constant [5 x i8] c"%f\09\0A\00"
@print10 = constant [5 x i8] c"%s\09\0A\00"
@print11 = constant [5 x i8] c"%s\09\0A\00"
@print12 = constant [5 x i8] c"%s\09\0A\00"
@print13 = constant [5 x i8] c"%s\09\0A\00"
@string10 = constant [6 x i8] c"hello\00"
@print14 = constant [5 x i8] c"%f\09\0A\00"
@print15 = constant [5 x i8] c"%f\09\0A\00"
define i32 @main() alwaysinline {
entry:
br label %main.bb0
main.bb0:
%main.bb0.tmp0 = bitcast [44 x i8]* @string0 to i8*
%main.bb0.tmp1 = bitcast [5 x i8]* @print0 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp1, i8* %main.bb0.tmp0)
%main.bb0.tmp2 = bitcast [31 x i8]* @string1 to i8*
%main.bb0.tmp3 = bitcast [5 x i8]* @print1 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp3, i8* %main.bb0.tmp2)
%main.bb0.tmp4 = bitcast [19 x i8]* @string2 to i8*
%main.bb0.tmp5 = bitcast [5 x i8]* @print2 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp5, i8* %main.bb0.tmp4)
%main.bb0.tmp6 = bitcast [113 x i8]* @string3 to i8*
store i8* %main.bb0.tmp6, i8** @global.page
%main.bb0.tmp8 = load i8** @global.page
%main.bb0.tmp9 = bitcast [5 x i8]* @print3 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp9, i8* %main.bb0.tmp8)
%main.bb0.tmp11 = bitcast [3 x i8]* @string4 to i8*
%main.bb0.tmp13 = call double@atof(i8* %main.bb0.tmp11)
%main.bb0.tmp10 = add double %main.bb0.tmp13, 1.000000
%main.bb0.tmp14 = bitcast [5 x i8]* @print4 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp14, double %main.bb0.tmp10)
%main.bb0.tmp15 = bitcast [7 x i8]* @string5 to i8*
%main.bb0.tmp16 = bitcast [5 x i8]* @print5 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp16, i8* %main.bb0.tmp15)
%main.bb0.tmp18 = bitcast [8 x i8]* @string6 to i8*
%main.bb0.tmp19 = bitcast [2 x i8]* @string7 to i8*
%main.bb0.tmp20 = call double@atof(i8* %main.bb0.tmp18)
%main.bb0.tmp21 = call double@atof(i8* %main.bb0.tmp19)
%main.bb0.tmp17 = mul double %main.bb0.tmp20, %main.bb0.tmp21
%main.bb0.tmp22 = bitcast [5 x i8]* @print6 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp22, double %main.bb0.tmp17)
%main.bb0.tmp24 = bitcast [6 x i8]* @string8 to i8*
%main.bb0.tmp25 = bitcast [6 x i8]* @string9 to i8*
%main.bb0.tmp26 = call i8*@stringcat(i8* %main.bb0.tmp24, i8* %main.bb0.tmp25)
%main.bb0.tmp27 = bitcast [5 x i8]* @print7 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp27, i8* %main.bb0.tmp26)
%main.bb0.tmp30 = add double 0.000000e+00, 5.000000
%main.bb0.tmp31 = bitcast [5 x i8]* @print8 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp31, double %main.bb0.tmp30)
%main.bb0.tmp33 = add double 0.000000e+00, 4.000000
%main.bb0.tmp35 = bitcast [5 x i8]* @print9 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp35, double %main.bb0.tmp33)
%main.bb0.tmp36 = sub i1 1, 0
%main.bb0.tmp38 = call i8*@btoa(i1 %main.bb0.tmp36)
%main.bb0.tmp39 = bitcast [5 x i8]* @print10 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp39, i8* %main.bb0.tmp38)
%main.bb0.tmp40 = sub i1 1, 0
%main.bb0.tmp42 = call i8*@btoa(i1 %main.bb0.tmp40)
%main.bb0.tmp43 = bitcast [5 x i8]* @print11 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp43, i8* %main.bb0.tmp42)
%main.bb0.tmp44 = add i1 0, 0
%main.bb0.tmp46 = call i8*@btoa(i1 %main.bb0.tmp44)
%main.bb0.tmp47 = bitcast [5 x i8]* @print12 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp47, i8* %main.bb0.tmp46)
%main.bb0.tmp48 = sub i1 1, 1
%main.bb0.tmp51 = call i8*@btoa(i1 %main.bb0.tmp48)
%main.bb0.tmp52 = bitcast [5 x i8]* @print13 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp52, i8* %main.bb0.tmp51)
%main.bb0.tmp54 = bitcast [6 x i8]* @string10 to i8*
%main.bb0.tmp55 = call i32@strlen(i8* %main.bb0.tmp54)
%main.bb0.tmp56 = sitofp i32 %main.bb0.tmp55 to double
%main.bb0.tmp57 = bitcast [5 x i8]* @print14 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp57, double %main.bb0.tmp56)
%main.bb0.tmp58 = add double 0.000000e+00, 10.000000
%main.bb0.tmp59 = bitcast [5 x i8]* @print15 to i8*
call i32 (i8*, ...)* @printf(i8* %main.bb0.tmp59, double %main.bb0.tmp58)
ret i32 0
}
define i8* @ftoa(double %num) alwaysinline {
entry:
%0 = tail call i8* @malloc(i32 256)
tail call void @llvm.memset.i32(i8* %0, i8 0, i32 256, i32 1)
%1 = tail call i32 (i8*, i8*, ...)* @sprintf(i8* %0, i8* getelementptr ([3 x i8]* @ftoa.str, i32 0, i32 0), double %num)
ret i8* %0
}
define i8* @stringcat(i8* %s1, i8* %s2) alwaysinline {
entry:
%0 = tail call i8* @malloc(i32 256)
tail call void @llvm.memset.i32(i8* %0, i8 0, i32 256, i32 1)
%1 = tail call i8* @strcpy(i8* %0, i8* %s1)
%2 = tail call i8* @strcat(i8* %0, i8* %s2)
ret i8* %0
}
define i1 @stringcmp(i8* %s1, i8* %s2, i32 %op) alwaysinline {
entry:
%0 = tail call i32 @strcmp(i8* %s1, i8* %s2)
	switch i32 %op, label %return [
i32 0, label %bb
i32 1, label %bb1
i32 2, label %bb2
i32 3, label %bb3
i32 4, label %bb4
i32 5, label %bb5
]
bb:
%1 = icmp slt i32 %0, 0
ret i1 %1
bb1:
%2 = icmp sgt i32 %0, 0
ret i1 %2
bb2:
%3 = icmp slt i32 %0, 1
ret i1 %3
bb3:
%4 = icmp sgt i32 %0, -1
ret i1 %4
bb4:
%5 = icmp ne i32 %0, 0	
ret i1 %5
bb5:
%6 = icmp eq i32 %0, 0	
ret i1 %6
return:
ret i1 undef
}
define i8* @btoa(i1 %i) alwaysinline {
entry:
        %.0 = select i1 %i, i8* getelementptr ([5 x i8]* @true.str, i32 0, i32 0), i8* getelementptr ([6 x i8]* @false.str, i32 0, i32 0)
ret i8* %.0
}
